.class public Lorg/microemu/device/impl/ui/DisplayableImplUI;
.super Ljava/lang/Object;
.source "DisplayableImplUI.java"

# interfaces
.implements Lorg/microemu/device/ui/DisplayableUI;


# instance fields
.field private commands:Ljava/util/Vector;

.field protected displayable:Ljavax/microedition/lcdui/Displayable;


# direct methods
.method protected constructor <init>(Ljavax/microedition/lcdui/Displayable;)V
    .locals 1
    .parameter "displayable"

    .prologue
    .line 46
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 44
    new-instance v0, Ljava/util/Vector;

    invoke-direct {v0}, Ljava/util/Vector;-><init>()V

    iput-object v0, p0, Lorg/microemu/device/impl/ui/DisplayableImplUI;->commands:Ljava/util/Vector;

    .line 47
    iput-object p1, p0, Lorg/microemu/device/impl/ui/DisplayableImplUI;->displayable:Ljavax/microedition/lcdui/Displayable;

    .line 48
    return-void
.end method

.method private updateCommands()V
    .locals 4

    .prologue
    .line 110
    invoke-static {}, Lorg/microemu/device/impl/ui/CommandManager;->getInstance()Lorg/microemu/device/impl/ui/CommandManager;

    move-result-object v2

    invoke-virtual {p0}, Lorg/microemu/device/impl/ui/DisplayableImplUI;->getCommandsUI()Ljava/util/Vector;

    move-result-object v3

    invoke-virtual {v2, v3}, Lorg/microemu/device/impl/ui/CommandManager;->updateCommands(Ljava/util/Vector;)V

    .line 111
    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletAccess()Lorg/microemu/MIDletAccess;

    move-result-object v1

    .line 112
    .local v1, ma:Lorg/microemu/MIDletAccess;
    if-nez v1, :cond_1

    .line 120
    :cond_0
    :goto_0
    return-void

    .line 115
    :cond_1
    invoke-virtual {v1}, Lorg/microemu/MIDletAccess;->getDisplayAccess()Lorg/microemu/DisplayAccess;

    move-result-object v0

    .line 116
    .local v0, da:Lorg/microemu/DisplayAccess;
    if-eqz v0, :cond_0

    .line 119
    invoke-interface {v0}, Lorg/microemu/DisplayAccess;->repaint()V

    goto :goto_0
.end method


# virtual methods
.method public addCommandUI(Lorg/microemu/device/ui/CommandUI;)V
    .locals 4
    .parameter "cmd"

    .prologue
    .line 52
    const/4 v0, 0x0

    .local v0, i:I
    :goto_0
    iget-object v2, p0, Lorg/microemu/device/impl/ui/DisplayableImplUI;->commands:Ljava/util/Vector;

    invoke-virtual {v2}, Ljava/util/Vector;->size()I

    move-result v2

    if-ge v0, v2, :cond_2

    .line 53
    iget-object v2, p0, Lorg/microemu/device/impl/ui/DisplayableImplUI;->commands:Ljava/util/Vector;

    invoke-virtual {v2, v0}, Ljava/util/Vector;->elementAt(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lorg/microemu/device/ui/CommandUI;

    if-ne p1, v2, :cond_1

    .line 76
    :cond_0
    :goto_1
    return-void

    .line 52
    :cond_1
    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    .line 60
    :cond_2
    const/4 v1, 0x0

    .line 61
    .local v1, inserted:Z
    const/4 v0, 0x0

    :goto_2
    iget-object v2, p0, Lorg/microemu/device/impl/ui/DisplayableImplUI;->commands:Ljava/util/Vector;

    invoke-virtual {v2}, Ljava/util/Vector;->size()I

    move-result v2

    if-ge v0, v2, :cond_3

    .line 62
    invoke-interface {p1}, Lorg/microemu/device/ui/CommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v2

    invoke-virtual {v2}, Ljavax/microedition/lcdui/Command;->getPriority()I

    move-result v3

    iget-object v2, p0, Lorg/microemu/device/impl/ui/DisplayableImplUI;->commands:Ljava/util/Vector;

    invoke-virtual {v2, v0}, Ljava/util/Vector;->elementAt(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lorg/microemu/device/ui/CommandUI;

    invoke-interface {v2}, Lorg/microemu/device/ui/CommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v2

    invoke-virtual {v2}, Ljavax/microedition/lcdui/Command;->getPriority()I

    move-result v2

    if-ge v3, v2, :cond_5

    .line 63
    iget-object v2, p0, Lorg/microemu/device/impl/ui/DisplayableImplUI;->commands:Ljava/util/Vector;

    invoke-virtual {v2, p1, v0}, Ljava/util/Vector;->insertElementAt(Ljava/lang/Object;I)V

    .line 64
    const/4 v1, 0x1

    .line 68
    :cond_3
    if-nez v1, :cond_4

    .line 70
    iget-object v2, p0, Lorg/microemu/device/impl/ui/DisplayableImplUI;->commands:Ljava/util/Vector;

    invoke-virtual {v2, p1}, Ljava/util/Vector;->addElement(Ljava/lang/Object;)V

    .line 73
    :cond_4
    iget-object v2, p0, Lorg/microemu/device/impl/ui/DisplayableImplUI;->displayable:Ljavax/microedition/lcdui/Displayable;

    invoke-virtual {v2}, Ljavax/microedition/lcdui/Displayable;->isShown()Z

    move-result v2

    if-eqz v2, :cond_0

    .line 74
    invoke-direct {p0}, Lorg/microemu/device/impl/ui/DisplayableImplUI;->updateCommands()V

    goto :goto_1

    .line 61
    :cond_5
    add-int/lit8 v0, v0, 0x1

    goto :goto_2
.end method

.method public getCommandsUI()Ljava/util/Vector;
    .locals 1

    .prologue
    .line 106
    iget-object v0, p0, Lorg/microemu/device/impl/ui/DisplayableImplUI;->commands:Ljava/util/Vector;

    return-object v0
.end method

.method public hideNotify()V
    .locals 0

    .prologue
    .line 94
    return-void
.end method

.method public invalidate()V
    .locals 0

    .prologue
    .line 102
    return-void
.end method

.method public removeCommandUI(Lorg/microemu/device/ui/CommandUI;)V
    .locals 1
    .parameter "cmd"

    .prologue
    .line 79
    iget-object v0, p0, Lorg/microemu/device/impl/ui/DisplayableImplUI;->commands:Ljava/util/Vector;

    invoke-virtual {v0, p1}, Ljava/util/Vector;->removeElement(Ljava/lang/Object;)Z

    .line 81
    iget-object v0, p0, Lorg/microemu/device/impl/ui/DisplayableImplUI;->displayable:Ljavax/microedition/lcdui/Displayable;

    invoke-virtual {v0}, Ljavax/microedition/lcdui/Displayable;->isShown()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 82
    invoke-direct {p0}, Lorg/microemu/device/impl/ui/DisplayableImplUI;->updateCommands()V

    .line 84
    :cond_0
    return-void
.end method

.method public setCommandListener(Ljavax/microedition/lcdui/CommandListener;)V
    .locals 0
    .parameter "l"

    .prologue
    .line 89
    return-void
.end method

.method public showNotify()V
    .locals 0

    .prologue
    .line 97
    invoke-direct {p0}, Lorg/microemu/device/impl/ui/DisplayableImplUI;->updateCommands()V

    .line 98
    return-void
.end method
